package 其他;

import java.lang.reflect.Method;

public class DEMO {
    public static void main(String[] args) {
        student student = new student();
        student.setName("yyf");
        try {
            System.out.println(test(student, 其他.student.class, "getName",null));
            Object[] aaa = {"游杨帆"};
            test(student, 其他.student.class, "setName",aaa,String.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String test(Object object,Class clazz,String methodStr, Object[] args, Class<?>... parameterTypes) throws Exception {
        Method method = clazz.getMethod(methodStr,parameterTypes);
        String name = (String) method.invoke(object,args);
        return name;
    }
}

class student{
    private String name;

    public String getName() {
        return name;
    }



    public void setName(String name) {
        System.out.println(name+"000000000000000000000000");
        this.name = name;
    }
}
